package lock;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author liuchaoqun
 * @date 2022/7/5
 * @Description 各种锁测试
 */
public class LockTest {
    public static void main(String[] args) throws Exception {
        ExecutorService pool = Executors.newFixedThreadPool(10);
        Lock lock = new ReentrantLock();
//        CountDownLatch countDownLatch = new CountDownLatch(10);
//        for (int i = 0; i < 10; i++) {
//            pool.submit(() -> {
//
//                try {
//                    System.out.println(Thread.currentThread().getName() + "开始累加");
//                    for (int j = 0; j < 100; j++) {
//                        IncrementData.lockAndFastIncrease(lock);
//                    }
//
//                } catch (Exception e) {
//                    e.printStackTrace();
//
//                }
//                countDownLatch.countDown();
//                System.out.println(Thread.currentThread().getName()+"累加结果" + IncrementData.sum);
//
//            });
//
//        }
//        countDownLatch.await();
//        pool.shutdownNow();
//        System.out.println("end");
    }
}
